package com.aac.demo;

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.os.Environment;

public class Global
{
  public static int BG_COLOR = 0;
  public static int MENU_QUIT = 0;
  public static int MENU_SAVE = 0;
  public static int MENU_SHARE = 0;
  public static Paint colorPaint;
  public static String currOpenFileName;
  public static int currPaintIdx = 0;
 // public static DlgColorPad dialogColorPad;
  //public static DlgErasePen dialogErasePen;

  //@Signature({"Ljava/util/Map", "<", "Ljava/lang/Float;", "Landroid/graphics/Bitmap;", ">;"})
  public static Map dynBitmap;
  public static int eraseIndex = 0;
  public static String fullDirName;
  public static boolean isSelectPad = false;
  public static int oldPenColor = 0;
  public static Bitmap orgBitmap;
  public static int penColorCurr = 0;
  public static int penMaxIndex = 0;
  public static int penMinIndex = 0;
  public static int screenX = 0;
  public static int screenY = 0;
  public static final String sharedFileName = "penman-shared";

  static
  {
    eraseIndex = 0;
    penMinIndex = 0;
    penMaxIndex = 3;
    boolean bool = isSelectPad;
    BG_COLOR = -1;
    MENU_SAVE = 1;
    MENU_SHARE = 2;
    MENU_QUIT = 3;
    colorPaint = null;
    penColorCurr = -16777216;
    oldPenColor = penColorCurr;
   // dialogColorPad = null;
   // dialogErasePen = null;
    currPaintIdx = -1;
    currOpenFileName = "";
    fullDirName = "";
    orgBitmap = null;
    dynBitmap = new HashMap();
  }

  private static void createFile(Context paramContext, int paramInt, File paramFile)
  {
    try
    {
      InputStream localInputStream = paramContext.getResources().openRawResource(paramInt);
      FileOutputStream localFileOutputStream = new FileOutputStream(paramFile);
      BufferedOutputStream localBufferedOutputStream = new BufferedOutputStream(localFileOutputStream);
      int i = 0;
      byte[] arrayOfByte = new byte[2048];
      i = localInputStream.read(arrayOfByte);
      if (i == -1)
      {
        localBufferedOutputStream.close();
        localInputStream.close();
        label64: return;
      }
      localBufferedOutputStream.write(arrayOfByte, 0, i);
    }
    catch (Exception localException)
    {
      
    }
  }

  public static void initialize(Context paramContext)
  {
    String str1 = String.valueOf(Environment.getExternalStorageDirectory().getAbsolutePath());
    fullDirName = str1 + "/penman";
    String str2 = fullDirName;
    File localFile1 = new File(str2);
    if (!localFile1.exists())
    {
      localFile1.mkdir();
      StringBuilder localStringBuilder1 = new StringBuilder();
      File localFile2 = localFile1.getAbsoluteFile();
      String str3 = localFile2 + "/plum.jpg";
      File localFile3 = new File(str3);
      createFile(paramContext, 2130837511, localFile3);
      StringBuilder localStringBuilder2 = new StringBuilder();
      File localFile4 = localFile1.getAbsoluteFile();
      String str4 = localFile4 + "/think.jpg";
      File localFile5 = new File(str4);
      createFile(paramContext, 2130837519, localFile5);
      StringBuilder localStringBuilder3 = new StringBuilder();
      File localFile6 = localFile1.getAbsoluteFile();
      String str5 = localFile6 + "/dragon.jpg";
      File localFile7 = new File(str5);
      createFile(paramContext, 2130837508, localFile7);
    }
    if (colorPaint == null)
    {
      colorPaint = new Paint();
      Paint localPaint = colorPaint;
      int i = penColorCurr;
      PorterDuff.Mode localMode = PorterDuff.Mode.XOR;
      PorterDuffColorFilter localPorterDuffColorFilter = new PorterDuffColorFilter(i, localMode);
      localPaint.setColorFilter(localPorterDuffColorFilter);
    }
 //   dialogColorPad = new DlgColorPad(paramContext);
   // dialogErasePen = new DlgErasePen(paramContext);
  }

  public static void resetColorFilter()
  {
    if (colorPaint == null)
      return;
    Paint localPaint = colorPaint;
    int i = penColorCurr;
    PorterDuff.Mode localMode = PorterDuff.Mode.XOR;
    PorterDuffColorFilter localPorterDuffColorFilter = new PorterDuffColorFilter(i, localMode);
    localPaint.setColorFilter(localPorterDuffColorFilter);
  }
}